
#ifndef _TTG_SERVICES_TASK_SCHEDULER_DEVICE_STATE_
#define _TTG_SERVICES_TASK_SCHEDULER_DEVICE_STATE_
#include "Common/Definitions.h"

#include "Runtime.Low/Devices.h"
#include "Runtime.Low/Threads.h"
#include "Runtime.Low/Utils/Parameters.h"

namespace ttg_internal
{
	namespace services
	{
		//Contains current information about devices.
		class DeviceState
		{
			private:
				ttg::threads::FastCriticalSection locker;
				ttg::devices::Device *device;
				ttg::utils::ParameterSet *device_filter;
				ttg::utils::Parameter<int> *max_task_count;
				ttg::utils::Parameter<int> *active_task_count;
				ttg::utils::Parameter<int> *available_task_count;
			public:
				//Creates device in the required owner-filter.
				DeviceState(ttg::devices::Device *device, ttg::utils::ParameterSet *owner_filter);
				//Returns locker for this device state.
				inline ttg::threads::FastCriticalSection &getLocker()
				{ return locker; }
				//Returns owner device.
				inline ttg::devices::Device *getOwner()
				{ return device; }
				//Returns count of active (unfinished) tasks.
				inline ttg::utils::Parameter<int> &getActiveTaskCount()
				{ return *active_task_count; }
				//Returns total count of tasks, that can be performed simultaneously by this device.
				inline ttg::utils::Parameter<int> &getTotalTaskCount()
				{ return *max_task_count; }
				//Returns count of untaken tasks, that are suitable for this device.
				inline ttg::utils::Parameter<int> &getAvailableTaskCount()
				{ return *available_task_count; }
				~DeviceState();
		};
	}
}

#endif
